﻿namespace Excel.EPPlus.Excel;

public class ColumnClassifier
{
    public enum ColumnType
    {
        Unknown,
        PartNumber,
        ReferenceDesignator,
        Quantity
    }

    public static ColumnType ClassifyColumn(string[] dataSample)
    {
        // 示例规则：简单假设Part Number包含字母数字混合，Ref Des以字母开始，Quantity为整数
        var isPartNumber = dataSample.Any(item => item.Any(char.IsLetter) && item.Any(char.IsDigit));
        var isRefDes = dataSample.All(item => !string.IsNullOrEmpty(item) && char.IsLetter(item[0]));
        var isQuantity = dataSample.All(item => int.TryParse(item, out _));

        if (isPartNumber) return ColumnType.PartNumber;
        else if (isRefDes) return ColumnType.ReferenceDesignator;
        else if (isQuantity) return ColumnType.Quantity;

        return ColumnType.Unknown;
    }
}
